package com.yk.spark.controller.hadoop;

import com.yk.spark.service.hadoop.api.IHadoopService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;

/**
 * Created by Limit on 2017/9/8.
 */
@Controller
@RequestMapping("/hadoop")
public class HadoopController {

    private final Log log= LogFactory.getLog(HadoopController.class);

    @Resource(name = "hadoopService")
    private IHadoopService hadoopService;

    @RequestMapping("getHadoopCatalog")
    @ResponseBody
    public Object getHadoopCatalog(@RequestParam(name = "id") String current, @RequestParam(name = "clusterId") String clusterId){
        this.log.info(clusterId);
        return this.hadoopService.queryChildren(current,clusterId);
    }
    @RequestMapping("createHadoopFolder")
    @ResponseBody
    public Object createHadoopFolder(@RequestParam(name = "id")String current,@RequestParam(name = "parent")String parent,@RequestParam(name = "clusterId") String clusterId){
        this.log.info(clusterId);
        return this.hadoopService.createNode(current,parent,clusterId);
    }
    @RequestMapping("deleteHadoopFolder")
    @ResponseBody
    public Object deleteHadoopFolder(@RequestParam(name = "id")String current ,@RequestParam(name = "parent")String parent,@RequestParam(name = "clusterId") String clusterId){
        this.log.info(clusterId);
        return this.hadoopService.deleteNode(current,parent,clusterId);
    }

}
